package org.exercise.record.utils;

public class ResponseUtils {

    private final static String SUCCESS = "操作成功";
    private final static String FAIL = "操作失败";

    public static <T> Result<T> makeSuccessResponse() {
        return new Result<T>().setCode(RetCode.SUCCESS).setMsg(SUCCESS);
    }

    public static <T> Result<T> makeSuccessResponse(T data) {
        return new Result<T>().setCode(RetCode.SUCCESS).setMsg(SUCCESS).setData(data);
    }

    public static <T> Result<T> makeSuccessResponse(String msg, T data) {
        return new Result<T>().setCode(RetCode.SUCCESS).setMsg(msg).setData(data);
    }

    public static <T> Result<T> makeErrorResponse() {
        return new Result<T>().setCode(RetCode.FAIL).setMsg(FAIL);
    }

    public static <T> Result<T> makeErrorResponse(String msg) {
        return new Result<T>().setCode(RetCode.FAIL).setMsg(msg);
    }
    public static <T> Result<T> makeErrorResponse(int code, String msg) {
        return new Result<T>().setCode(code).setMsg(msg);
    }

    public static <T> Result<T> makeResponse(int code, String msg) {
        return new Result<T>().setCode(code).setMsg(msg);
    }

    public static <T> Result<T> makeResponse(int code, String msg, T data) {
        return new Result<T>().setCode(code).setMsg(msg).setData(data);
    }
}